package oktx.sample.dubbo;

import com.alibaba.druid.pool.xa.DruidXADataSource;
import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.context.annotation.Bean;

import javax.sql.XADataSource;

/**
 * Created by dave on 18-5-20 上午10:30.
 */
@EnableDubbo
@SpringBootApplication
public class Application1 {

    @Bean
    public XADataSource xaDataSource(DataSourceProperties properties) {
        DruidXADataSource dataSource = new DruidXADataSource();
        dataSource.setUrl(properties.getUrl());
        dataSource.setUsername(properties.getUsername());
        dataSource.setPassword(properties.getPassword());
        dataSource.setMinIdle(5);
        dataSource.setMaxActive(50);
        dataSource.setInitialSize(5);
        return dataSource;
    }

    public static void main(String[] args) throws Exception {
        SpringApplication.run(Application1.class, args);

        while (true) {
            System.in.read();
        }
    }
}
